package ru.megazlo.basemvc.dao.repository;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import ru.megazlo.basemvc.dao.dto.News;
import ru.megazlo.basemvc.dto.view.NewsListView;

public interface NewsRepository extends JpaRepository<News, Long> {

	@Query("select new ru.megazlo.basemvc.dto.view.NewsListView(n.id, n.comments.size, n.createdDate, n.title, n.shortText) from News n")
	Page<NewsListView> findShortNews(Pageable pg);
}
